package com.atguigu.tingshu.album.api;

import com.atguigu.tingshu.album.service.BaseCategoryService;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.common.result.ResultCodeEnum;
import com.atguigu.tingshu.model.album.BaseAttribute;
import com.atguigu.tingshu.vo.album.AlbumCategoryVo;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Tag(name = "分类管理")
@RestController
@RequestMapping(value="/api/album/category")
@SuppressWarnings({"unchecked", "rawtypes"})
public class BaseCategoryApiController {
	
	@Autowired
	private BaseCategoryService baseCategoryService;

	@GetMapping(value = "/getBaseCategoryList")
	public Result<List<AlbumCategoryVo>> getBaseCategoryList(){
		List<AlbumCategoryVo> albumCategoryVoList = baseCategoryService.getBaseCategoryList();
		return Result.build(albumCategoryVoList, ResultCodeEnum.SUCCESS);
	}

	@GetMapping(value = "/findAttribute/{category1Id}")
	public Result<List<BaseAttribute>> findAttributeByCategoryId(@PathVariable(value = "category1Id") Long categoryId){
		List<BaseAttribute> baseAttributesList = baseCategoryService.findAttributeByCategoryId(categoryId);
		return Result.build(baseAttributesList, ResultCodeEnum.SUCCESS);
	}

}

